/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.synjones.zeuscloudapp.service;

import com.synjones.zeuscloudapp.util.ReqBean;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author tnnan
 * @param <T>
 */
@Component
public abstract class AbstractCommonServiceImpl<T,A> implements IDataPackService<A> {

    public abstract T buildData(String jsonData);
        
    public ReqBean<T> getReqBean(HttpServletRequest request){
        String organizationCode = request.getHeader("organizationCode");
        String apiVersion = request.getHeader("apiVersion");
        String dateTime = request.getHeader("dateTime");
        String appVersion = request.getHeader("appVersion");
        String clientType = request.getHeader("clientType");
        String clientMark = request.getHeader("clientMark");
        String iplanetdirectorypro = request.getHeader("iplanetdirectorypro");
        String imei = request.getHeader("imei");
        String clientIp = request.getHeader("clientIp");
        String magic = request.getHeader("magic");
        return new ReqBean(organizationCode, apiVersion, dateTime, appVersion, clientType, clientMark, 
                iplanetdirectorypro, imei, clientIp, magic, this.buildData(request.getParameter("data")));
    }
    
}
